package com.wsd.common.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 日期格式化工具
 */
public class DateUtils {

    private static final SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd");
    private static final SimpleDateFormat format2 = new SimpleDateFormat("yyyyMMddHHmmss");

    /**
     * 格式化日期
     * @param date 要格式化的日期
     * @return yyyyMMdd
     */
    public static String toNString(Date date) {
        if (date == null) return null;
        return format1.format(date);
    }

    public static String toNDateTimeString(Date date) {
        if (date == null) return null;
        return format2.format(date);
    }


    public static String currentDateNString() {
        return toNString(new Date());
    }

    public static String currentDateTimeNString() {
        return toNDateTimeString(new Date());
    }

}
